package com.lambda.use;

import org.junit.Test;

/**
 * 功能描述
 *
 * @author: jichao.huang
 * @date: 2025年06月04日 17:27
 */
public class FunctionInterfaceUse {
    @Test
    public void test() {
        GreetingService greetingService = message -> System.out.println("Hello " + message);
        greetingService.sayMessage("World");

        greetingService.defaultMethod();
        GreetingService.staticMethod();
    }

    @Test
    public void testCalculator() {
        Calculator  add = (a, b) -> a + b;
        Calculator  subtract = (a, b) -> a - b;

        int result = add.calculate(10, 5);
        add.printResult(result);

        result = subtract.calculate(10, 5);
        subtract.printResult(result);
    }

    @Test
    public void test2() {
        ObjectMethodFunctionalInterface functionalInterface = () -> System.out.println("Hello World");
        ObjectMethodFunctionalInterface functionalInterface2 = () -> System.out.println("Hello World");
        System.out.println(functionalInterface.equals(functionalInterface2));
        System.out.println(functionalInterface.equals(functionalInterface));
    }
}
